<?
include_once 'library/GridView.class.php';

class RuangDinginGridReport extends GridView{
	function RuangDinginGridReport($data, $config){		
		parent::__construct($data, $config);
	}
	
	function createBody(){
		
		$body = '
					<table cellspacing="0" cellpadding="0" border="0" style="">
						<tbody>
		';
		$i = 0;
		if( count($this->data) > 0 ){
			foreach( $this->data as $d ){
				if( $d['usia'] < 4 ){
					if( $i%2 )
						$body .= '<tr>';
					else
						$body .= '<tr class="erow">';
				}
				else{
					$class = 'warn2';
					if( $d['usia'] > 6)
						$class = 'warn1';
						
					$body .= '<tr class="'.$class.'">';					
				}
				
				for($j=0; $j<count($this->col_title); $j++){
						$c     = $this->col_name[$j];
						$width  = isset($this->col->w[$c]) ? $this->col->w[$c] : 130;
			
						$body .= '<td class="'.($this->sort_by==$c? "sorted" : "").'"><div style="text-align: center; width: '.$width.'px;">'.$d[$c].'</div></td>';
					}
					
					$th_operation = '<td class=""><div style="text-align: center; width: 100px;">';
					if( $this->canEdit || $this->canDelete ){
						if( $this->canEdit )
							$th_operation .= '<a class="operation edit" href="index.php?action=edit&bagian='.$_GET['bagian'].'&subbagian='.$_GET['subbagian'].'&id='.$d['id'].'">Edit</a>';
							
						if( $this->canEdit && $this->canDelete )
							$th_operation .= ' ';
						
						if( $this->canDelete )
							$th_operation .= '<a class="operation delete" href="index.php?action=delete&bagian='.$_GET['bagian'].'&subbagian='.$_GET['subbagian'].'&id='.$d['id'].'">Delete</a>';
					}
					$th_operation .= '</div></td>';
					$body .= $th_operation;

					$body .= '</tr>';	
				$i++;
			}
		}
		else
			$body .= '<tr><td colspan="'.count($this->col_title).'">No data</td></tr>';

		$body .= '
						</tbody>
					</table>
				</div>
		';
		
		return $body;
	}	
}
?>
